﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Windows.Navigation.Primitives
{
    public class NavigationHandlerInvoker
    {
        public void Invoke(INavigationHandler handler, NavigationContext context)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            if (context == null)
                throw new ArgumentNullException("context");

            handler.ProcessRequest(context);

            if (context.View == null)
            {
                // try to active
                if (context.ViewModel != null)
                    context.View = this.ActiveView(context.ViewModel);
                else if (context.RequestUri != null)
                    context.View = this.ActiveView(context.RequestUri);
                if (context.View == null)
                    throw new InvalidOperationException("Active view failed");
            }
        }

        public object ActiveView(object viewModel)
        {
            throw new NotImplementedException();
        }

        public object ActiveView(Uri uri)
        {
            throw new NotImplementedException();
        }
    }
}